﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Order1 : System.Web.UI.Page
{

   // private string uploadDir; //uploadDir变量存放文件保存路径   
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserId"] == null)//用户未登录，返回登录界面
        {
            Response.Redirect("Login.aspx");
        }
        else
        {
            //按钮颜色变化
            LinkButton1.BackColor = System.Drawing.Color.LimeGreen;
            //页面首次加载且订单ID不为空
            MyDataDataContext db = new MyDataDataContext();
            //获取要显示的记录对象

            var order = from r in db.Order
                         join g in db.SaleOfGoods 
                         on r.GoodsID equals g.GoodsID
                         where r.StateOfOrder == 1 & r.BuyerID == Session["UserId"].ToString()//1表示订单处于进行中状态，0表示订单已完成, -1表示失败                                                                                               
                         select new
                         {
                             r.OrderID,
                             r.GoodsName,
                             g.Type,
                             r.Price,
                             g.GoodsPicture,
                             r.Time
                         };//映射需要显示的字段

                       
            gvSaleOfGoods.DataSource = order;
            gvSaleOfGoods.DataBind();
            if (gvSaleOfGoods.Rows.Count != 0)
            {
                
                lblCart.Text = "";
            }
            else
            {
                
                lblCart.Text = "无正在进行中的订单！";
            }
        }

   
    }

}
